<!--
 * @Description: 
 * @Author: ZachGmy
 * @Date: 2022-08-23 17:08:23
 * @LastEditors: HeAo
 * @LastEditTime: 2022-08-26 16:40:51
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      color: white;
      font-size: 20px;
    }

    #outer {
      width: 300px;
      height: 300px;
      background-color: red;
    }

    #center {
      width: 200px;
      height: 200px;
      background-color: blue;
    }

    #inner {
      width: 100px;
      height: 100px;
      background-color: green;
    }
  </style>
</head>

<body>
  <div id="outer" onclick="outer()">outer
    <div id="center" onclick="center()">center
      <div id="inner" onclick="inner()">inner</div>
    </div>
  </div>
  <script>
    /*
    当我们点击inner时，会产生冒泡 inner——>center——>outer——>body——>html——>Document
    */
    // outer
    function outer() {
      console.log('outer');
    }
    // center
    function center() {
      // 阻止事件冒泡
      event.stopPropagation()
      console.log('center');
    }
    // inner
    function inner() {
      // 阻止事件冒泡
      event.stopPropagation()
      console.log('inner');
    }
  </script>
</body>

</html>